package xio.ccf_201409;

import java.util.Scanner;

/**
 * 201409-1 相邻数对 100分
 * Created by Xio on 2017/11/6 0006.
 */
public class AdjacentPairs {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] data = new int[10001];
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            data[a] =a;
        }

        int pairCount =0;
        for (int i = 1; i < data.length-1; i++) {
            if (data[i] == 0){
                continue;
            }
            if ( data[i+1] !=0){
                pairCount++;
            }
        }

        System.out.println(pairCount+"");
    }
}
